package com.jxw.utils;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.support.v4.view.ViewCompat;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.TextView;
import com.jxw.launcher.R;
import java.lang.reflect.Field;

/* loaded from: classes.dex */
public class StrokeTextView extends TextView {
    private boolean mDrawSideLine;
    private int mInnerColor;
    private int mOuterColor;
    private int mStrokeSize;
    TextPaint m_TextPaint;

    public StrokeTextView(Context context, int i, int i2) {
        super(context);
        this.mDrawSideLine = false;
        this.m_TextPaint = getPaint();
        this.mInnerColor = i2;
        this.mOuterColor = i;
    }

    public StrokeTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.mDrawSideLine = false;
        this.m_TextPaint = getPaint();
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.StrokeTextView);
        this.mInnerColor = obtainStyledAttributes.getColor(1, ViewCompat.MEASURED_SIZE_MASK);
        this.mOuterColor = obtainStyledAttributes.getColor(2, ViewCompat.MEASURED_SIZE_MASK);
        this.mStrokeSize = (int) obtainStyledAttributes.getDimension(3, 0.0f);
        this.mDrawSideLine = obtainStyledAttributes.getBoolean(0, false);
    }

    public StrokeTextView(Context context, AttributeSet attributeSet, int i, int i2, int i3) {
        super(context, attributeSet, i);
        this.mDrawSideLine = false;
        this.m_TextPaint = getPaint();
        this.mInnerColor = i3;
        this.mOuterColor = i2;
    }

    @Override // android.widget.TextView, android.view.View
    protected void onDraw(Canvas canvas) {
        if (this.mDrawSideLine) {
            setTextColorUseReflection(this.mOuterColor);
            this.m_TextPaint.setStrokeWidth(this.mStrokeSize);
            this.m_TextPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            this.m_TextPaint.setFakeBoldText(true);
            this.m_TextPaint.setShadowLayer(5.0f, 0.0f, 0.0f, 0);
            super.onDraw(canvas);
            setTextColorUseReflection(this.mInnerColor);
            this.m_TextPaint.setStrokeWidth(0.0f);
            this.m_TextPaint.setFakeBoldText(false);
            this.m_TextPaint.setShadowLayer(0.0f, 0.0f, 0.0f, 0);
        } else {
            this.m_TextPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 0));
            this.m_TextPaint.setColor(getResources().getColor(R.color.xbwxz));
        }
        super.onDraw(canvas);
    }

    private void setTextColorUseReflection(int i) {
        try {
            Field declaredField = TextView.class.getDeclaredField("mCurTextColor");
            declaredField.setAccessible(true);
            declaredField.set(this, Integer.valueOf(i));
            declaredField.setAccessible(false);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e2) {
            e2.printStackTrace();
        } catch (NoSuchFieldException e3) {
            e3.printStackTrace();
        }
        this.m_TextPaint.setColor(i);
    }

    public void setInnerColor(int i, int i2) {
        this.mInnerColor = i;
        this.mOuterColor = i2;
        postInvalidate();
    }

    public void setOuterColor(int i) {
        this.mOuterColor = i;
        postInvalidate();
    }

    public void setStrokeSize(int i) {
        this.mStrokeSize = i;
        postInvalidate();
    }

    public void setDrawSideLine(boolean z) {
        this.mDrawSideLine = z;
        postInvalidate();
    }
}
